package 蓝桥真题;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 回路计数 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=31,M=600;
       static int h[]=new int[N],e[]=new int[M],ne[]=new int[M],idx,res;
       static boolean st[]=new boolean[N];
       static int gcd(int a,int b){
    	      return b>0?gcd(b,a%b):a;
       }
       static void add(int a,int b){
    	      e[idx]=b;ne[idx]=h[a];h[a]=idx++;
       }
       static void dfs(int dot,int d){
    	      if(st[dot]){
    	    	  if(d==21&&dot==1)
    	    	  res++;
    	    	  return;
    	      }
    	      st[dot]=true;
    	      for(int i=h[dot];i!=-1;i=ne[i]){
    	    	  dfs(e[i],d+1);
    	      }
    	      st[dot]=false;
       }
       public static void main(String[] args) {
    	      Arrays.fill(h,-1);
		      for(int i=1;i<=21;i++)
		    	  for(int j=i+1;j<=21;j++){
		    		  if(gcd(i,j)==1){
		    			  add(i,j);
		    			  add(j,i);
		    		  }
		    	  }
		      dfs(1,0);
		      System.out.print(res);
	}
}
